/**
 * Description: 无名管道的基本操作
 * File: pipe.c |Time: 2021-04-06 13:46
 */
#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
    int fd[2];
    char buf[100];
    pipe(fd);

    int res = write(fd[1], "abcdefg1234567", 10);

    if (res == -1) {
        perror("write");
        return -1;
    }

    res = read(fd[0], buf, 5);
    res = read(fd[0], buf, 5);

    if (res == -1) {
        perror("read");
        return -1;
    }

    printf("buf = %s\n", buf);

    return 0;
}
